package com.jiang.专题.动态规划.Q746;

/**
 * @author Jiang
 * @version 1.0
 * @date 2024/12/24 21:08
 */
class Solution {
    public int minCostClimbingStairs(int[] cost) {
        int len = cost.length;
        if (len == 2) return Math.min(cost[0], cost[1]);
        for (int i = 2; i < len; i++) {
            cost[i] += Math.min(cost[i - 1], cost[i - 2]);
        }
        return Math.min(cost[len - 1], cost[len - 2]);
    }
}
